use serde::{Deserialize, Serialize};
use serde_with::base64::Base64;
use wanmesh_common::net::wireguard;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct EndpointWireguardConfig {
    pub config: WireguardConfig,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all(serialize = "PascalCase", deserialize = "PascalCase"))]
pub struct WireguardConfig {
    pub interface: WireguardInterfaceConfig,
}

#[serde_with::serde_as]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all(serialize = "PascalCase", deserialize = "PascalCase"))]
pub struct WireguardInterfaceConfig {
    #[serde_as(as = "Base64")]
    pub private_key: [u8; wireguard::key::KEY_LEN],
    #[serde(skip_serializing_if = "Option::is_none")]
    pub listen_port: Option<u16>
}